package com.lv.suyiyong.hfr.moudel

import androidx.databinding.ObservableField
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.lv.common.base.BaseViewModel
import com.lv.common.network.model.DataResult
import com.lv.service.bean.SpuInfoBean
import com.lv.service.network.BaseYgxRsp
import com.lv.service.repo.UserInfo
import com.lv.suyiyong.hfr.bean.VersionListBean
import com.lv.suyiyong.hfr.repo.IMainResource
import retrofit2.http.QueryMap

/**
 * 版权：Zhujiang 个人版权
 * @author zhujiang
 * 版本：1.5
 * 创建日期：2020/5/19
 * 描述：PlayAndroid
 *
 */
class MainViewModel(private val resource: IMainResource) : BaseViewModel() {
    var obMobile = ObservableField<String>()
    var obPassword = ObservableField<String>()
    var obPasswordCon = ObservableField<String>()
    var obIsAgree = ObservableField<Boolean>()
    val liveUser = MutableLiveData<UserInfo>()

    /**
     * 更新TOKEN
     */
    suspend fun refreshtoken(
    ) = resource.refreshtoken()




//    val findProsLiveData: LiveData<FindProsBean> = resource.findProsDateRsp
//    fun findPros(map: Map<String, String>) =
//        serverAwait {
//            resource.findPros(map)
//        }


    /**
     * 商品基本相关信息
     */
    val spuCategoryLiveData: LiveData<SpuInfoBean> = resource.spuCategoryDateRsp
    fun spuCategory() =
        serverAwait {
            resource.spuCategory()
        }

    /**
     * 推送安卓
     */
    suspend fun saveTX(@QueryMap map: Map<String, String>): DataResult<BaseYgxRsp> =
        resource.saveTX(map)
}